/**
 * Copyright &copy; 2012-2017 <a href="https://vivo.com">vivo</a> All rights reserved.
 */
package com.vivo.employee.entity;

import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import org.hibernate.validator.constraints.Length;

import java.util.Calendar;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;

import com.thinkgem.jeesite.common.persistence.DataEntity;

/**
 * 员工信息Entity
 * @author jyangye
 * @version 2017-12-28
 */
public class ViEmployee extends DataEntity<ViEmployee> {

    private static final long serialVersionUID = 1L;
//	private String compId;		// 组织机构ID
//	private String deptId;		// 部门ID
//	private String postId;		// 岗位ID


    private Office comp;		// 组织机构ID
    private Office dept;		// 部门ID
    private Office post;		// 岗位ID

    private String postDetail;  // 细分岗位


    private String name;		// 员工姓名
    private String sex;		// 性别
    private String telephone;		// 联系电话
    private String curStateId;		// 当前状态
    private String empAttribute;		// 工作性质
    private String contractNo;		// 合同编号
    private String censusRegister;		// 户籍所在地
    private Date birthDate;		// 生日日期
    private String age;		// 年龄
    private String maritalStatus;		// 婚姻状态
    private String address;		// 家庭地址
    private String clothesSizeId;		// 服装尺码
//	private String superId;		// 上级员工

    private ViEmployee sp;

    private String educateId;		// 学历ID
    private Date educateDate;		// 毕业时间
    private String school;		// 毕业院校
    private String professional;		// 所学专业
    private String schoolType;		// 学校类型
    private String emergencyName;		// 紧急联系人
    private String emergencyPhone;		// 紧急联系号码
    private String code;		// 员工编号
    private String identityCard;		// 身份证号
    private Date indutyDate;		// 入职时间
    private Date ondutyDate;		// 转正时间
    private Date outdutyDate;		// 离职时间
    private String workMonth;		// 工龄(月）
    private String wageBase;		// 工资基数
    private String levelId;		// 员工级别
    private String socialNo;		// 社保号码
    private String socialCurMoney;		// 当前缴存金额
    private String fundNo;		// 公积金
    private String fundCurMoney;		// 公积金缴存基数
    private String cardNo;		// 银行卡号
    private String depositBank;		// 开户银行

    private String cardNoTwo;		// 银行卡号2
    private String depositBankTwo;		// 开户银行2



    private Date contractOneEndDate; // 第一合同截至日期
    private Date contractTwoEndDate; // 第二合同截至日期

    private String isActive;		// 是否可用
    private Date beginIndutyDate;		// 开始 入职时间
    private Date endIndutyDate;		// 结束 入职时间
    private Date beginOutdutyDate;		// 开始 离职时间
    private Date endOutdutyDate;		// 结束 离职时间


    private String dgAttribute; // 导购属性
    private String postLevel; //职位级别
    private String isWitness; // 是否为管培生

    private String isXiaozhao; // 是否校招

    private String postName;

    private String zone;

    private Date changePostDate; //转岗时间

    private String errMsg; // 导入错误信息

    private String isSaleryByLevel;

    private String isPreOutduty; // 是否待离职

    private String isUpdOffice; // 是否同步组织机构

    private String isPartTime; //是否兼职

    private String updStatus;
    private Date sysUpdDate;

    private String newEid;
    private String oldEid;

    private Office pComp;
    private Office pDept;
    private Office pPost;

    private String saleryType; // 薪酬类型

    private String specialTag; // 特殊标签


    private String empAttrCond; // 工作性质条件


    private String indutyTimeType;

    private String isXcjs; // 是否计算薪酬


    private String lastLevelId;  // 上一级别
    private Date levelChgDate; // 级别修改日期

    public ViEmployee() {
        super();
    }

    public ViEmployee(String id){
        super(id);
    }


    @Length(min=1, max=32, message="组织机构长度必须介于 1 和 32 之间")
    @ExcelField(title="组织机构", align=2, sort=20)
    public Office getComp() {
        return comp;
    }

    public void setComp(Office comp) {
        this.comp = comp;
    }


    @Length(min=1, max=32, message="部门长度必须介于 1 和 32 之间")
    @ExcelField(title="*部门", align=2, sort=30)
    public Office getDept() {
        return dept;
    }

    public void setDept(Office dept) {
        this.dept = dept;
    }


    @Length(min=1, max=32, message="岗位长度必须介于 1 和 32 之间")
    @ExcelField(title="*岗位", align=2, sort=40)
    public Office getPost() {
        return post;
    }

    public void setPost(Office post) {
        this.post = post;
    }

    @Length(min=0, max=32, message="细分岗位长度必须介于 1 和 32 之间")
    @ExcelField(title="细分岗位", align=2, sort=45)
    public String getPostDetail() {
        return postDetail;
    }

    public void setPostDetail(String postDetail) {
        this.postDetail = postDetail;
    }

    @Length(min=1, max=16, message="员工姓名长度必须介于 1 和 16 之间")
    @ExcelField(title="*员工姓名", align=2, sort=50)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Length(min=1, max=1, message="性别长度必须介于 1 和 1 之间")
    @ExcelField(title="*性别", align=2, sort=60, dictType="sex")
    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Length(min=1, max=20, message="身份证号长度必须介于 1 和 20 之间")
    @ExcelField(title="*身份证号", align=2, sort=65, isText = true)
    public String getIdentityCard() {
        return identityCard;
    }

    public void setIdentityCard(String identityCard) {
        this.identityCard = identityCard;
    }


    @Length(min=1, max=16, message="联系电话长度必须介于 1 和 16 之间")
    @ExcelField(title="*联系电话", align=2, sort=70, isText = true)
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Length(min=0, max=32, message="学历ID长度必须介于 0 和 32 之间")
    @ExcelField(title="*学历", align=2, sort=75,dictType = "emp_educate")
    public String getEducateId() {
        return educateId;
    }

    public void setEducateId(String educateId) {
        this.educateId = educateId;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="*入职时间", align=2, sort=80)
    public Date getIndutyDate() {
        return indutyDate;
    }

    public void setIndutyDate(Date indutyDate) {
        this.indutyDate = indutyDate;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="*转正时间", align=2, sort=90)
    public Date getOndutyDate() {
        return ondutyDate;
    }

    public void setOndutyDate(Date ondutyDate) {
        this.ondutyDate = ondutyDate;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="转岗时间", align=2, sort=100)
    public Date getChangePostDate() {
        return changePostDate;
    }

    public void setChangePostDate(Date changePostDate) {
        this.changePostDate = changePostDate;
    }


    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="离职时间", align=2, sort=110)
    public Date getOutdutyDate() {
        return outdutyDate;
    }

    public void setOutdutyDate(Date outdutyDate) {
        this.outdutyDate = outdutyDate;
    }


    @Length(min=0, max=20, message="婚姻状态长度必须介于 0 和 20 之间")
    @ExcelField(title="婚姻状态", align=2, sort=120, dictType = "emp_marital_status")
    public String getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    @Length(min=1, max=32, message="当前状态长度必须介于 1 和 32 之间")
    @ExcelField(title="当前状态", align=2, sort=130, dictType = "emp_cur_status")
    public String getCurStateId() {
        return curStateId;
    }

    public void setCurStateId(String curStateId) {
        this.curStateId = curStateId;
    }

    @Length(min=1, max=1, message="工作性质长度必须介于 1 和 1 之间")
    @ExcelField(title="工作性质", align=2, sort=140, dictType = "emp_people_attr")
    public String getEmpAttribute() {
        return empAttribute;
    }

    public void setEmpAttribute(String empAttribute) {
        this.empAttribute = empAttribute;
    }







    public String getIsWitness() {
        return isWitness;
    }

    public void setIsWitness(String isWitness) {
        this.isWitness = isWitness;
    }


    public String getIsXiaozhao() {
        return isXiaozhao;
    }

    public void setIsXiaozhao(String isXiaozhao) {
        this.isXiaozhao = isXiaozhao;
    }



    public String getContractNo() {
        return contractNo;
    }

    public void setContractNo(String contractNo) {
        this.contractNo = contractNo;
    }


    public String getCensusRegister() {
        return censusRegister;
    }

    public void setCensusRegister(String censusRegister) {
        this.censusRegister = censusRegister;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="生日日期(身份证)", align=2, sort=190)
    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    @Length(min=0, max=11, message="年龄长度必须介于 0 和 11 之间")
    @ExcelField(title="年龄(身份证)", align=2, sort=200)
    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }




    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    public String getClothesSizeId() {
        return clothesSizeId;
    }

    public void setClothesSizeId(String clothesSizeId) {
        this.clothesSizeId = clothesSizeId;
    }


    @Length(min=0, max=32, message="上级员工长度必须介于 0 和 32 之间")
    @ExcelField(title="上级员工", align=2, sort=230)
    public ViEmployee getSp() {
        return sp;
    }

    public void setSp(ViEmployee sp) {
        this.sp = sp;
    }


    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="毕业时间", align=2, sort=240)
    public Date getEducateDate() {
        return educateDate;
    }

    public void setEducateDate(Date educateDate) {
        this.educateDate = educateDate;
    }

    @Length(min=0, max=64, message="毕业院校长度必须介于 0 和 64 之间")
    @ExcelField(title="毕业院校", align=2, sort=250)
    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    @Length(min=0, max=32, message="所学专业长度必须介于 0 和 32 之间")
    @ExcelField(title="所学专业", align=2, sort=260)
    public String getProfessional() {
        return professional;
    }

    public void setProfessional(String professional) {
        this.professional = professional;
    }


    public String getSchoolType() {
        return schoolType;
    }

    public void setSchoolType(String schoolType) {
        this.schoolType = schoolType;
    }

    @Length(min=0, max=32, message="紧急联系人长度必须介于 0 和 32 之间")
    @ExcelField(title="紧急联系人", align=2, sort=280)
    public String getEmergencyName() {
        return emergencyName;
    }

    public void setEmergencyName(String emergencyName) {
        this.emergencyName = emergencyName;
    }

    @Length(min=0, max=16, message="紧急联系号码长度必须介于 0 和 16 之间")
    @ExcelField(title="紧急联系号码", align=2, sort=290)
    public String getEmergencyPhone() {
        return emergencyPhone;
    }

    public void setEmergencyPhone(String emergencyPhone) {
        this.emergencyPhone = emergencyPhone;
    }

    @Length(min=0, max=30, message="员工编号长度必须介于 0 和 30 之间")
    @ExcelField(title="员工编号", align=2, sort=300)
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }


    @Length(min=0, max=11, message="工龄(年）长度必须介于 0 和 11 之间")
    @ExcelField(title="工龄(年）", align=2, sort=310)
    public String getWorkMonth() {
        return workMonth;
    }

    public void setWorkMonth(String workMonth) {
        this.workMonth = workMonth;
    }


    public String getWageBase() {
        return wageBase;
    }

    public void setWageBase(String wageBase) {
        this.wageBase = wageBase;
    }


    @Length(min=0, max=32, message="员工级别长度必须介于 0 和 32 之间")
    @ExcelField(title="员工级别", align=2, sort=330,dictType = "emp_level")
    public String getLevelId() {
        return levelId;
    }

    public void setLevelId(String levelId) {
        this.levelId = levelId;
    }


    @Length(min=0, max=1, message="薪酬类型长度必须介于 0 和 1 之间")
    @ExcelField(title="薪酬类型", align=2, sort=330,dictType = "salery_type")
    public String getSaleryType() {
        return saleryType;
    }

    public void setSaleryType(String saleryType) {
        this.saleryType = saleryType;
    }


    //    @Length(min = 0, max = 32, message = "职位级别长度必须介于 0 和 32 之间")
//    @ExcelField(title = "职级", align = 2, sort = 335, dictType = "emp_post_level")
    public String getPostLevel() {
        return postLevel;
    }

    public void setPostLevel(String postLevel) {
        this.postLevel = postLevel;
    }


    public String getSocialNo() {
        return socialNo;
    }

    public void setSocialNo(String socialNo) {
        this.socialNo = socialNo;
    }


    public String getSocialCurMoney() {
        return socialCurMoney;
    }

    public void setSocialCurMoney(String socialCurMoney) {
        this.socialCurMoney = socialCurMoney;
    }

    public String getFundNo() {
        return fundNo;
    }

    public void setFundNo(String fundNo) {
        this.fundNo = fundNo;
    }

    public String getFundCurMoney() {
        return fundCurMoney;
    }

    public void setFundCurMoney(String fundCurMoney) {
        this.fundCurMoney = fundCurMoney;
    }

    @Length(min=0, max=32, message="银行卡号长度必须介于 0 和 32 之间")
    @ExcelField(title="银行卡号", align=2, sort=380)
    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    @Length(min=0, max=50, message="开户银行长度必须介于 0 和 50 之间")
    @ExcelField(title="开户银行", align=2, sort=390)
    public String getDepositBank() {
        return depositBank;
    }

    public void setDepositBank(String depositBank) {
        this.depositBank = depositBank;
    }


    @Length(min=0, max=32, message="银行卡号2长度必须介于 0 和 32 之间")
    @ExcelField(title="银行卡号2", align=2, sort=392)
    public String getCardNoTwo() {
        return cardNoTwo;
    }

    public void setCardNoTwo(String cardNoTwo) {
        this.cardNoTwo = cardNoTwo;
    }

    @Length(min=0, max=50, message="开户银行2长度必须介于 0 和 50 之间")
    @ExcelField(title="开户银行2", align=2, sort=395)
    public String getDepositBankTwo() {
        return depositBankTwo;
    }

    public void setDepositBankTwo(String depositBankTwo) {
        this.depositBankTwo = depositBankTwo;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="第一合同截至日期", align=2, sort=400)
    public Date getContractOneEndDate() {
        return contractOneEndDate;
    }

    public void setContractOneEndDate(Date contractOneEndDate) {
        this.contractOneEndDate = contractOneEndDate;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    @ExcelField(title="第二合同截至日期", align=2, sort=410)
    public Date getContractTwoEndDate() {
        return contractTwoEndDate;
    }

    public void setContractTwoEndDate(Date contractTwoEndDate) {
        this.contractTwoEndDate = contractTwoEndDate;
    }

    public String getIsActive() {
        return isActive;
    }

    public void setIsActive(String isActive) {
        this.isActive = isActive;
    }

    public Date getBeginIndutyDate() {
        return beginIndutyDate;
    }

    public void setBeginIndutyDate(Date beginIndutyDate) {
        this.beginIndutyDate = beginIndutyDate;
    }

    public Date getEndIndutyDate() {
        return endIndutyDate;
    }

    public void setEndIndutyDate(Date endIndutyDate) {
        this.endIndutyDate = endIndutyDate;
    }

    public Date getBeginOutdutyDate() {
        return beginOutdutyDate;
    }

    public void setBeginOutdutyDate(Date beginOutdutyDate) {
        this.beginOutdutyDate = beginOutdutyDate;
    }

    public Date getEndOutdutyDate() {
        return endOutdutyDate;
    }

    public void setEndOutdutyDate(Date endOutdutyDate) {
        this.endOutdutyDate = endOutdutyDate;
    }

    @Length(min=0, max=11, message="导购属性长度必须介于 0 和 11 之间")
    @ExcelField(title="导购属性", align=2, sort=420, dictType = "emp_attr")
    public String getDgAttribute() {
        return dgAttribute;
    }

    public void setDgAttribute(String dgAttribute) {
        this.dgAttribute = dgAttribute;
    }


    public String getZone() {
        return zone;
    }

    public void setZone(String zone) {
        this.zone = zone;
    }

    public String getPostName() {
        return postName;
    }

    public void setPostName(String postName) {
        this.postName = postName;
    }


    @Length(min=0, max=1, message="是否计算薪酬长度必须介于 0 和 1 之间")
    @ExcelField(title="薪酬计算", align=2, sort=425,dictType = "yes_no")
    public String getIsXcjs() {
        return isXcjs;
    }

    public void setIsXcjs(String isXcjs) {
        this.isXcjs = isXcjs;
    }

    @Override
    public String toString() {
        return name;
    }


    @ExcelField(type = 1, title = "导入状态", align = 2, sort = 430)
    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }


    public String getIsSaleryByLevel() {
        return isSaleryByLevel;
    }

    public void setIsSaleryByLevel(String isSaleryByLevel) {
        this.isSaleryByLevel = isSaleryByLevel;
    }

    public String getIsPreOutduty() {
        return isPreOutduty;
    }

    public void setIsPreOutduty(String isPreOutduty) {
        this.isPreOutduty = isPreOutduty;
    }


    public String getIsUpdOffice() {
        return isUpdOffice;
    }

    public void setIsUpdOffice(String isUpdOffice) {
        this.isUpdOffice = isUpdOffice;
    }


    public String getIsPartTime() {
        return isPartTime;
    }

    public void setIsPartTime(String isPartTime) {
        this.isPartTime = isPartTime;
    }

    public String getUpdStatus() {
        return updStatus;
    }

    public void setUpdStatus(String updStatus) {
        this.updStatus = updStatus;
    }

    public Date getSysUpdDate() {
        return sysUpdDate;
    }

    public void setSysUpdDate(Date sysUpdDate) {
        this.sysUpdDate = sysUpdDate;
    }

    public Office getpComp() {
        return pComp;
    }

    public void setpComp(Office pComp) {
        this.pComp = pComp;
    }

    public Office getpDept() {
        return pDept;
    }

    public void setpDept(Office pDept) {
        this.pDept = pDept;
    }

    public Office getpPost() {
        return pPost;
    }

    public void setpPost(Office pPost) {
        this.pPost = pPost;
    }


    public String getNewEid() {
        return newEid;
    }

    public void setNewEid(String newEid) {
        this.newEid = newEid;
    }

    public String getOldEid() {
        return oldEid;
    }

    public void setOldEid(String oldEid) {
        this.oldEid = oldEid;
    }

    public String getLastLevelId() {
        return lastLevelId;
    }

    public void setLastLevelId(String lastLevelId) {
        this.lastLevelId = lastLevelId;
    }

    public Date getLevelChgDate() {
        return levelChgDate;
    }

    public void setLevelChgDate(Date levelChgDate) {
        this.levelChgDate = levelChgDate;
    }

    public String getSpecialTag() {
        return specialTag;
    }

    public void setSpecialTag(String specialTag) {
        this.specialTag = specialTag;
    }

    public String getEmpAttrCond() {
        return empAttrCond;
    }

    public void setEmpAttrCond(String empAttrCond) {
        this.empAttrCond = empAttrCond;
    }

    public void setEmpAttrCondByEmpAttr() {
        if (this.empAttribute == null) {
            this.empAttrCond = null;
            return;
        }

        String[] empAttrArr = this.empAttribute.split(",");
        if (empAttrArr.length == 0) {
            this.empAttrCond = null;
            return;
        }

        this.empAttrCond = " (";

        for (int i = 0; i < empAttrArr.length; i++) {
            if (empAttrArr[i].equals("")) {
                continue;
            }

            if (i == empAttrArr.length -1) {
                this.empAttrCond += "'" + empAttrArr[i] + "'";
            } else {
                this.empAttrCond += "'" + empAttrArr[i] + "',";
            }
        }

        this.empAttrCond += ") ";
    }

    public String getIndutyTimeType() {
        return indutyTimeType;
    }

    public void setIndutyTimeType(String indutyTimeType) {
        this.indutyTimeType = indutyTimeType;
    }

    public void updIndutyTime() {
        Date nowDate = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(nowDate);

        if (StringUtils.isBlank(indutyTimeType)) {
            return;
        }

        switch (Integer.parseInt(indutyTimeType)) {
            // 0~3个月
            case 1:
                cal.add(Calendar.MONTH, -3);
                endIndutyDate = null;
                beginIndutyDate = cal.getTime();
                break;

            // 4~6个月
            case 2:
                cal.add(Calendar.MONTH, -3);
                endIndutyDate = cal.getTime();
                cal.add(Calendar.MONTH, -3);
                beginIndutyDate = cal.getTime();
                break;

            // 6~12月
            case 3:
                cal.add(Calendar.MONTH, -6);
                endIndutyDate = cal.getTime();
                cal.add(Calendar.MONTH, -6);
                beginIndutyDate = cal.getTime();
                break;

            // 12月以上
            case 4:
                cal.add(Calendar.MONTH, -12);
                endIndutyDate = cal.getTime();
                break;

            default:
                break;
        }
    }


    /**
     * 查询参数
     */
    public void updQueryParam() {
        if (getEmpAttribute() == null) {
            setEmpAttribute("1,2");
        }

        setEmpAttrCondByEmpAttr();

        updIndutyTime();
    }
}